package ca.tatham.triplipse.views.table;

import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.swt.graphics.Image;
import org.openrdf.model.Literal;

import ca.tatham.triplipse.RdfStatement;
import ca.tatham.triplipse.views.RdfStatementLabelProvider;

public class TableRdfStatementLabelProvider extends RdfStatementLabelProvider implements
		ITableLabelProvider {

	public String getColumnText(Object obj, int columnIndex) {
		try {
			RdfStatement rdfStatement = (RdfStatement) obj;
			switch (columnIndex) {
			case 0:
				return getResourceText(rdfStatement.getSubject().toString());
			case 1:
				return getResourceText(rdfStatement.getPredicate().toString());
			case 2:
				if (rdfStatement.getObject() instanceof Literal) {
					return getLiteralText(rdfStatement.getObject().toString());
				}
				return getResourceText(rdfStatement.getObject().toString());
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return "?";
	}

	public Image getColumnImage(@SuppressWarnings("unused")
	Object obj, @SuppressWarnings("unused")
	int index) {
		return null;
	}

}
